package com.linux.huhx.thread3.threadState_1;

/**
 * @Author: huhx
 * @Date: 2017-10-31 下午 2:44
 * State: NEW, RUNNABLE, TERMINATED
 */
public class StateRun1 {
    public static void main(String[] args) throws InterruptedException {
        MyThread myThread = new MyThread();
        System.out.println("name " + Thread.currentThread().getName() + " 1 " + myThread.getState()); // name main 1 NEW
        Thread.sleep(1000);
        myThread.start();
        Thread.sleep(1000);
        System.out.println("name " + Thread.currentThread().getName() + " 2 " + myThread.getState()); // name main 2 TERMINATED
    }
}

class MyThread extends Thread {

    public MyThread() {
        System.out.println("name " + Thread.currentThread().getName() + " constructor " + Thread.currentThread().getState()); // name main constructor RUNNABLE
    }

    @Override
    public void run() {
        System.out.println("name " + Thread.currentThread().getName() + " run method " + Thread.currentThread().getState()); // name Thread-0 run method RUNNABLE
    }
}
/*
name main constructor RUNNABLE
name main 1 NEW
name Thread-0 run method RUNNABLE
name main 2 TERMINATED
 */